Skip to content

Conversation

@kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Aug 12, 2021

Fix and improve nsenter_test.go (originally part of #3114).

thaJeztah
thaJeztah previously approved these changes Aug 17, 2021
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

left some comments/questions, but don't think they're blockers

@kolyshkin
Copy link
Contributor Author

Rebased; renamed reapChild to reapChildren; moved Wait4 to before pid checks.

@kolyshkin kolyshkin requested a review from thaJeztah August 17, 2021 19:51
thaJeztah
thaJeztah previously approved these changes Aug 17, 2021
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@kolyshkin
Copy link
Contributor Author

@AkihiroSuda PTAL

@kolyshkin
Copy link
Contributor Author

Had to rebase after #3144 merge. @thaJeztah @AkihiroSuda PTAL

thaJeztah
thaJeztah previously approved these changes Aug 18, 2021
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kolyshkin kolyshkin added this to the 1.1.0 milestone Aug 31, 2021

if err := cmd.Start(); err != nil {
t.Fatalf("nsenter failed to start %v", err)
t.Fatal("nsenter failed to start:", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? The previous form seems completely legit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A semicolon was missing. While adding it, I guess I decided to simplify it, that's it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other reason is, I was using the same form in the subsequent patches, so I added it here, too, for uniformity.

Nevermind though, I re-did this commit so it uses %v in this and similar cases, and moved the patch to be the last one.

PTAL @AkihiroSuda

1. Make sure we close all file descriptors at the end of the test.

2. Make sure we close child fds after the start.

3. Use newPipe for logs as well, for simplicity and uniformity.

Signed-off-by: Kir Kolyshkin <[email protected]>
The test was not working since at least commit 64bb59f
renamed pid to stage2_pid (or maybe even earlier), so the pid
was never received (i.e. pid.Pid was 0).

The problem was not caught because os.FindProcess never return an error
on Unix.

Factor out and fix pid decode function:
 - use DisallowUnknownInput to get error if JSON will be changed;
 - check pids to make sure they are valid
 - and use unix.Wait4 to reap zombies.

Signed-off-by: Kir Kolyshkin <[email protected]>
Instead of reading a single message, do read all the logs from the init,
and use DisallowUnknownFields for stricter checking.

While at it, use reapChildren to reap zombies (and add an extra check).

Signed-off-by: Kir Kolyshkin <[email protected]>
 - add missing colons before error message;
 - unify error messages after cmd.Start and cmd.Wait, so that they show
   context and the error itself.

Signed-off-by: Kir Kolyshkin <[email protected]>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still LGTM

@thaJeztah thaJeztah merged commit 963e014 into opencontainers:master Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants